<header>
    <div class="header4">
        <section>
            <h1><a href="/"><?= get_bloginfo('name'); ?></a></h1>
            <img src="<?= STATIC_PATH ?>/img/menu.svg">
        </section>

        <nav class="grid">
            <?php foreach (
                get_categories(array(
                    'taxonomy'   => 'category',
                    'hide_empty' => false, // Include empty categories
                    'orderby'    => 'name',
                    'order'      => 'ASC',
                )) as $vo
            ): ?>
                <?php if (intval($vo->parent) == 0): ?>
                    <a href="/category/<?= $vo->slug ?>"><?= $vo->name ?></a>
                <?php endif; ?>
            <?php endforeach; ?>
        </nav>
    </div>
</header>

<script>
    const menu = document.querySelector('header>div.header4>section>img');
    const nav = document.querySelector('header>div.header4>nav');

    menu.addEventListener('click', () => {
        nav.classList.toggle('show');
        window.masker.toggle();
        window.masker.node().addEventListener('click',() => {
            nav.classList.remove('show');
            window.masker.hide();
        })
    });
</script>

<style>
    header {
        backdrop-filter: blur(10px);
        background-color: rgba(25, 25, 25, .8);
        position: relative;
        z-index: 888;
    }

    div.header4 {
        display: grid;
        grid-template-rows: 4rem;
        position: relative;
    }

    div.header4>section {
        display: flex;
        justify-content: end;
        justify-items: end;
        align-items: center;
        gap: var(--gap);
        z-index: 666;
    }

    div.header4>section>h1>a {
        color: var(--color-primary);
    }

    div.header4>section>img {
        height: 3rem;
        width: 3rem;
        display: none;
    }

    div.header4>nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: end;
        transition: var(--transition);
        top: 100%;
    }

    div.header4>nav>a {
        padding: var(--gap);
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius);
        transition: var(--transition);
        background-color: var(--color-primary);

    }

    @keyframes goout {
        from {
            height: 40rem;
            width: 30rem;
            top: 6rem;
            right: 0;
        }

        to {
            height: 0;
            width: 0;
            top: 100vh;
            right: 100vw;
        }
    }

    @keyframes goin {
        from {
            width: 0;
            top: 100vh;
            right: 100vw;
        }

        to {
            width: 30rem;
            top: 6rem;
            right: 0;
        }
    }

    @media (max-width: 768px) {
        div.header4>nav.show {
            visibility: visible;
            height: auto;
            animation: goin .3s ease-in-out;
            width: 80%;
            right: 0;
            padding: 1rem;
            overflow-y: scroll;
        }

        div.header4>section>img {
            display: block;
        }

        div.header4>section>h1 {
            font-size: 1.5rem;
        }

        div.header4>nav {
            flex-direction: column;
            align-items: start;
            height: 0;
            width: 0;
            overflow: hidden;
          
            position: absolute;
            background-color: rgba(25, 25, 25, .8);
            animation: goout .3s ease-in-out;
        }

        div.header4>nav>a {
            width: 100%;
            text-align: center;
        }
    }
    @media (max-width: 576px) {
        div.header4>nav.show {
            width: 100%;
        }
    }
</style>